package com.example.shiwuyouproject.ui

import android.annotation.SuppressLint
import android.webkit.WebSettings
import com.example.shiwuyouproject.base.BaseVmActivity
import com.example.shiwuyouproject.databinding.ActivityWebviewBinding
import com.example.shiwuyouproject.ui.modelview.WebViewViewModel

/**
 * 所有涉及h5页面内部展示
 */
class WebViewActivity:BaseVmActivity<ActivityWebviewBinding, WebViewViewModel>() {


    override fun viewModelClass(): Class<WebViewViewModel> = WebViewViewModel::class.java

    override fun getViewBinding(): ActivityWebviewBinding {
        return ActivityWebviewBinding.inflate(layoutInflater)
    }
    private var myUrl=""
    override fun initView() {
        myUrl= intent.getStringExtra("url").toString()


    }

    @SuppressLint("SetJavaScriptEnabled")
    override fun initData() {
        mBinding.myWebView.settings.setSupportZoom(true)//缩放
        mBinding.myWebView.settings.builtInZoomControls = true
        mBinding.myWebView.settings.displayZoomControls = false
        mBinding.myWebView.settings.cacheMode = WebSettings.LOAD_NO_CACHE;
        mBinding.myWebView.settings.allowFileAccess = true
        mBinding.myWebView.settings.setGeolocationEnabled(true)
        mBinding.myWebView.settings.domStorageEnabled = true
        mBinding.myWebView.settings.userAgentString
        mBinding.myWebView.settings.javaScriptEnabled = true
        mBinding.myWebView.settings.javaScriptCanOpenWindowsAutomatically = true
        mBinding.myWebView.settings.loadWithOverviewMode = true
        mBinding.myWebView.settings.defaultTextEncodingName = "UTF-8"
        mBinding.myWebView.settings.setAppCacheEnabled(false)
        mBinding.myWebView.loadUrl(myUrl)
    }

    override fun setListener() {
        mBinding.titleBar.tvBack.setOnClickListener { finish() }
    }

    override fun observe() {


    }
}